package com.edu.lingnan.springcloud.service;

import com.edu.lingnan.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author shaosen
 * @Description //TODO
 * @Date 21:14 2020/6/5
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            public Dept queryById(Long id) {
                return new Dept()
                        .setDeptno(id)
                        .setDname("id=>"+ id + "没有对应的信息，客服端提供了降级的信息，这个服务现在已经被关闭了")
                        .setDb_source("没有数据~");
            }

            public List<Dept> queryAll() {
                return null;
            }

            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
